export const FILE_TYPE = {
    MUSIC:  0,
    VIDEO:  1,
    PHOTO:  2,
    ZIP:    3,
    WORD:   4,
    PPT:    5,
    EXCEL:  6,
    PDF:    7,
    TEXT:   8,
    FILE:   9
}

export const defaultSort = (a, b)=>{
    if (a.file_type===b.file_type || (a.is_directory&&b.is_directory))
        return a.name<b.name?-1:1;
    if (a.is_directory)
        return -1;
    if (b.is_directory)
        return 1;
    const aT = FILE_TYPE[a.file_type], bT = FILE_TYPE[b.file_type];
    if (aT===undefined)
        return 1;
    if (bT===undefined)
        return -1
    return aT-bT;
}
export const timeSort = (a, b)=>{
    if(a.is_directory&&b.is_directory)
        return a.created_at-b.created_at;
    if(a.is_directory)
        return -1;
    if(b.is_directory)
        return  1;
    return a.created_at-b.created_at;
}
export const nameSort = (a, b)=>{
    if(a.is_directory&&b.is_directory)
        return a.name<b.name?-1:1;
    if(a.is_directory)
        return -1;
    if(b.is_directory)
        return 1;
    return a.name<b.name?-1:1;
}